package org.llc.gof.behavior.chain.basic;


/**
 * @author Fancy
 */
public abstract class Handler {

    private Handler nextHandler;

    public final Response handlerMessage(Request request) {

        Response response = null;

        if (this.getHandlerLevel().equals(request.getRequestLevel())) {
            response = this.echo(request);
        } else {
            if (this.nextHandler != null) {
                response = this.nextHandler.handlerMessage(request);
            } else {
            }
        }
        return response;
    }


    public void setNext(Handler _handler) {
        this.nextHandler = _handler;
    }

    protected abstract Level getHandlerLevel();

    protected abstract Response echo(Request request);

}
